﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ThermalEquipmentDesign.Model;
using System.Windows.Input;
using ThermalEquipmentDesign.Model.CoolingTower;
using System.Windows;
using ThermalEquipmentDesign.Reference_Path;
using ThermalEquipmentDesign.Reference_Path.CoolingTower;

namespace ThermalEquipmentDesign.ViewModel
{
    public class CoolingTowerViewModel : ObservableObject
    {
        //  Declare the Object from CoolingTower model.
        //  
        private CoolingTower oCoolingtower = new CoolingTower();
        private CoolingtowerResult oresult = new CoolingtowerResult();
        private CoolingTowerModel oCoolingTowerModel;
        private ICommand calculate;
        //  Declare tooltip used for help
        private String stooltip = "Press F1 for Help";
        //  Declare the object tooltip
        public String sTooltip
        {
            get { return stooltip; }
            set { stooltip = value; }
        }
        //  Create the oResult object with CoolingtowerResult type for View
        public CoolingtowerResult oResult
        {
            get { return oresult; }
            set
            {
                if (value != oresult)
                {
                    oresult = value;
                    OnPropertyChanged("oresult");
                }
            }
        }

        //  Create the oCoolingTower object 

        public CoolingTower ocoolingTower
        {
            get { return oCoolingtower; }
            set
            {
                if (value != oCoolingtower)
                {
                    oCoolingtower = value;
                    OnPropertyChanged("ocoolingtower");
                }
            }
        }
        //  Declare the event for calculcate button 
        public ICommand Calculate
        {
            
            get
            {
                if (calculate == null)
                {
                    calculate = new RelayCommand(
                        param => ImplementCalculation()
                    );
                }
                return calculate;
            }
        }
        /// <summary>
        /// Implement calculation and report
        /// </summary>
        public void ImplementCalculation()
        {
           
            CoolingTowerModel coolingModel = new CoolingTowerModel();
            oresult = coolingModel.ImplementCalculation(oCoolingtower);
        }
        //  Load Reference for the helping 
        public void LoadReference(string sIndex)
        {            
            System.Windows.Forms.Help.ShowHelp(null, ReferencePath.ReferenceFile, System.Windows.Forms.HelpNavigator.Index, CoolingTowerReference.ResourceManager.GetString(sIndex));
        }
        
    }
}
    

